{% comment %}
# Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{% endcomment %}

{% load i18n %}

<div class="bubble">
  <span class="title-row">
    <span id="bubble-title" class="title">{{special.title.value|escape}}</span>
    {% if user %}
      {% comment %}
      #i18n: Link to edit the data for a hospital record.
      {% endcomment %}
      <a href="#" onclick="inplace_edit_start('{{edit_url|escape}}'); return false">{% trans "Edit this record" %}</a>
      {% if show_edit_by_email %}
        <span class="sep">|</span>
        <a onclick="edit_by_email_open();" href="#">
          {% comment %}
          #i18n: Link to a feature allowing a user to edit a record by email
          {% endcomment %}
          {% trans "Edit by email" %}
        </a>
      {% endif %}
      <span class="sep">|</span>
      <a onclick="subscribe_on_off(this,
        {% if subscribed %}true{% else %}false{% endif %}, '{{subdomain}}',
        '{{subject_name|escape}}', '{{frequency}}', '{{settings_url}}');"
        href="#">
        {% if subscribed %}
          {% comment %}
          #i18n: Label to unsubscribe from a subject
          {% endcomment %}
          {% trans "Unsubscribe" %}
        {% else %}
          {% comment %}
          #i18n: Label to subscribe to a subject
          {% endcomment %}
          {% trans "Subscribe to email updates" %}
        {% endif %}
      </a>
      {% if purge_permitted %}
        <span class="sep">|</span>
        <a id='purge-delete' style="color: #f00;" href="#" onclick="purge_subject('{{subdomain}}',
          '{{subject_name|escape}}');"><b>Delete Permanently (ADMIN ONLY)</b></a>
      {% endif %}
    {% else %}
      {% comment %}
      #i18n: Link to sign in to edit the data for a hospital record.
      {% endcomment %}
      <a href="{{login_url|escape}}">{% trans "Sign in to edit" %}</a>
      {% if show_edit_by_email %}
        <span class="sep">|</span>
        <a onclick="edit_by_email_open();" href="#">
          {% comment %}
          #i18n: Link to a feature allowing a user to edit a record by email
          {% endcomment %}
          {% trans "Edit by email" %}
        </a>
      {% endif %}
    {% endif %}
  </span>
  {% if show_edit_by_email %}
  <div id="edit-by-email-insert" style="display:none; background: #eee; padding: 6px; margin: 0px 14px 4px 0px">
    <div id="edit-by-email-form">
      {% comment %}
      #i18n: Explains the edit by email feature.
      {% endcomment %}
      {% trans "You can edit this facility by sending email.<br>Enter your email address. We will send you simple instructions to get started." %}
      <div style="padding-top: 5px">
        {% comment %}
        #i18n: Explains the edit by email feature.
        {% endcomment %}
        {% trans "Email" %}
        <input type="text" id="edit-by-email-address" value="{{email}}"></input>
        <span id="edit-by-email-buttons">
          <button onclick="edit_by_email_send('{{subdomain}}', '{{subject_name|escape}}', '{{edit_by_email_url}}')">
            {% comment %}
            #i18n: Button text to submit a form
            {% endcomment %}
            {% trans "Go" %}
          </button>
          <button onclick="edit_by_email_close()">
            {% comment %}
            #i18n: Button text to cancel a form
            {% endcomment %}
            {% trans "Cancel" %}
          </button>
        </span>
        <span id="edit-by-email-sending" style="display:none">
          {% comment %}
          #i18n: Waiting message to send email
          {% endcomment %}
          {% trans "Sending..." %}
        </span>
        <div id="edit-by-email-error" style="color:#900"></div>
      </div>
    </div>
    <div id="edit-by-email-success" style="display:none">
      {% comment %}
      #i18n: Message on successfully sent email
      {% endcomment %}
      {% trans "Success! Sent mail to:" %}
      <span id="edit-by-email-address-span"></span>
      <br>
      <button onclick="edit_by_email_close()">
        {% comment %}
        #i18n: Button text to close a form
        {% endcomment %}
        {% trans "Close" %}
      </button>
    </div>
    <div id="edit-by-email-fail" style="display:none">
      {% comment %}
      #i18n: Error message.
      {% endcomment %}
      {% trans "An error has occurred. Please try again later." %}
      <br>
      <button onclick="edit_by_email_close()">
        {% comment %}
        #i18n: Button text to close a form
        {% endcomment %}
        {% trans "Close" %}
      </button>
    </div>
  </div>
  {% endif %}
  <h2>
    {% block ids %}
      {% if special.id.raw %}
        {% comment %}
        #i18n: Proper name of an ID for a health facility
        {% endcomment %}
        {% trans "ID" %}: {{special.id.value|escape}} &#xb7;
      {% endif %}
      {% if special.alt_id.raw %}
        {% comment %}
        #i18n: Proper name of an alternate ID for a health facility
        {% endcomment %}
        {% trans "Alternate ID" %}: {{special.alt_id.value|escape}}
      {% endif %}
      {% if special.maps_link.raw %}
        <a target="_blank" href="{{special.maps_link.value|escape}}">
        {% comment %}
        #i18n: View in Google Mapmaker
        {% endcomment %}
        {% trans "View in Google MapMaker" %}</a>
      {% endif %}
      <br>
    {% endblock ids %}
    {% comment %}
    #i18n: Label for a date-time when the data was last updated
    {% endcomment %}
    {% trans "Last updated" %}: {{last_updated|escape}}
  </h2>
  {% ifequal special.operational_status.raw 'CLOSED_OR_CLOSING' %}
    <div style="color:#a00; font-size:14px;">
      {% comment %}
      #i18n: Note that a health facility has been marked closed.
      {% endcomment %}
      {% blocktrans %}<strong>Note:</strong> This facility has been marked closed.{% endblocktrans %}
    </div>
  {% endifequal %}
  {% if special.alert_status.raw %}
    <div style="color:#a00; font-size: 14px;">
      {% comment %}
      #i18n: Note that a health facility is on alert.
      {% endcomment %}
      <strong>{% trans "Alert" %}:</strong> {{special.alert_status.raw}}
    </div>
  {% endif %}
  <table class="scorecard" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        {% comment %}
        #i18n: Heading for number of available beds at a hospital
        {% endcomment %}
        <th class="availability" width="1%">{% trans "availability" %}</th>
        {% comment %}
        #i18n: Heading for number of total beds at a hospital
        {% endcomment %}
        <th class="capacity" width="1%">{% trans "capacity" %}</th>
        {% comment %}
        #i18n: Heading for servies available at a hospital
        #i18n: (eg, orthopedics, cardiology)
        {% endcomment %}
        <th class="services">{% trans "services" %}</th>
      </tr>
      <tr>
        {% if special.total_beds.specified or special.available_beds.specified %}
          <td class="availability">
            <div id="bubble-availability" class="number">
              {{special.available_beds.value|escape}}
            </div>
          </td>
          <td class="capacity">
            <div id="bubble-capacity" class="number">
              {{special.total_beds.value|escape}}
            </div>
          </td>
        {% else %}
        <td class="no-information" colspan="2">
          {% if general.phone and general.phone.raw %}
          {% comment %}
          #i18n: Indicates a user should call for availability of beds and
          #i18n: services at a hospital.
          {% endcomment %}
          {% trans "Please call for availability information." %}
          {% else %}
          {% comment %}
          #i18n: Indicates there is no availability information for this 
          #i18n: hospital.
          {% endcomment %}
          {% trans "No availability information" %}
          {% endif %}
        </td>
        {% endif %}
        <td class="services">
          {{special.services.value|escape}}
        </td>
      </tr>
    </tbody>
  </table>
  <div id="bubble-tabs">
    <ul>
      <li><a href="#bubble-tab-details">
          {% comment %}
          #i18n: Header for details about a facility
          {% endcomment %}
          {% trans "Facility details" %}</a></li> 
      <li><a href="#bubble-tab-history">
          {% comment %}
          #i18n: Header for the history of changes in data for a facility
          {% endcomment %}
          {% trans "Change details" %}</a></li>
    </ul>
    <div id="bubble-tab-details">
      <table class="details" cellpadding="0" cellspacing="0">
        <tbody>
          <tr class="item">
            <td class="label" width="20%">
              {% comment %}
              #i18n: Header for a street address
              {% endcomment %}
              {% trans "Address" %}
            </td>
            <td class="value">
              {{special.address.value|escape}}
            </td>
            <td class="value">
              {% comment %}
              #i18n: Geographic coordinates of a location on earth.
              {% endcomment %}
              {% trans "Location:" %} {{special.location.value|escape}}
            </td>
          </tr>
          {% for attribute in general %}
          <tr class="item">
            <td class="label">{{attribute.label|escape}}</td>
            <td class="value" colspan="2"
              >{{attribute.value|escape|linebreaksbr}}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
    <div id="bubble-tab-history">
      <table class="details" cellpadding="0" cellspacing="0">
        <thead>
          <tr>
            {% comment %}
            #i18n: Header for a record of a change to a facility detail
            {% endcomment %}
            <th>{% trans "Change" %}</th>
            {% comment %}
            #i18n: Header a column of user who made the edits
            {% endcomment %}
            <th>{% trans "Edited by" %}</th>
            {% comment %}
            #i18n: Header a column of comment about why a change was made
            {% endcomment %}
            <th>{% trans "Change note" %}</th>
            {% comment %}
            #i18n: Header for date and time of a change record
            {% endcomment %}
            <th>{% trans "Date and time" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for attribute in details %}
          <tr>
            <td>{{attribute.label|escape}}: {{attribute.value|escape}}</td>
            <td>{{attribute.author|escape}}, {{attribute.affiliation|escape}}</td>
            <td>{{attribute.comment|escape}}</td>
            <td>{{attribute.date|escape}}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
